package yuan.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yuan.common.MyTimer;

@RestController
@RequestMapping("timer")
public class TimerCtrl {

    @RequestMapping("test")
    public String test(){
        return MyTimer.testTimerSample();
    }

    @RequestMapping("test2")
    public String test2(){

        Runnable task = new Runnable() {
            @Override
            public void run() {
                while (true){
                    MyTimer.testTimerSample();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        Thread t = new Thread(task);
        t.start();
        return MyTimer.testTimerSample();
    }
}
